<template>
  <div class="panel-group">
    <div
      v-for="(item,index) in cardList"
      :key="index"
      :class="['card-panel-col',item.icon]"
    >
      <div class="card-panel"  @click="goToPage(item.routerName)">
        <div class="card-panel-icon-wrapper icon-normal">
          <svg-icon :icon-class="item.icon" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            {{ item.name }}
          </div>
          <count-to :start-val="0" :end-val="item.value" :duration="2600" class="card-panel-num"/>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import CountTo from 'vue-count-to'

export default {
  props: {
    cardList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  components: {
    CountTo
  },
  methods: {
    goToPage(routerName) {
      this.$router.push({name: routerName})
    }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  display: flex;
  flex-wrap: wrap;
  width: calc(100% + 30px);
  margin-left: -15px;
  margin-right: -15px;

  .card-panel-col {
    box-sizing: border-box;
    width: 33.33%;
    padding: 0 15px;
    margin-bottom: 30px;
  }

  @mixin iconStyle($color){
    .icon-normal {
      color: $color;
    }

    .card-panel:hover{
      .icon-normal {
        background: $color;
        color: #fff;
      }
    }

  }

  .matter1{
    @include iconStyle(#40c9c6);
  }

  .subject1{
    @include iconStyle(#36a3f7);
  }

  .net{
    @include iconStyle(#f4516c);
  }

  .guide{
    @include iconStyle(#46b47b);
  }

  .zizhu{
    @include iconStyle(#a065ef);
    svg{
      transform: scale(1.3);
    }
  }

  .model1{
    @include iconStyle(#ff5a00);
  }

  .card-panel {
    display: flex;
    align-items: center;
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 30px rgba(0, 0, 0, .08);
    border-color: rgba(0, 0, 0, .05);
    border-radius: 2px;
    transition: transform .3s;

    .card-panel-icon-wrapper{
      display: inline-block;
    }

    .card-panel-icon-wrapper {
      float: left;
      margin-left: 20px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      font-size: 48px;
    }

    $color: #34bfa3;

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }
    }

    .card-panel-description {
      width: 100%;
      flex: 1;
      margin: 20px 20px 20px 0;
      text-align: right;
      font-weight: bold;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      font-family: 微软雅黑;

      .card-panel-text {
        line-height: 18px;
        color: #666;
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 26px;
        color: #666;
      }
    }
  }
}

@media (min-width: 1830px) {
  .panel-group {
    .card-panel-col {
      width: calc(100% / 6);
    }
  }
}

@media (max-width: 1400px) {
  .panel-group {
    .card-panel-col {
      width: calc(100% / 3);
    }
  }
}

@media (max-width: 1100px) {
  .panel-group {
    .card-panel-col {
      width: 50%;
    }
  }
}
</style>
